p<-5
n<-150
library(mnormt)
library(MASS)
library(mvtnorm)
set.seed(3)
m<-rnorm(p,sd=sqrt(1))
s<-1/rgamma(p,3,2)
x<-rmvnorm(n,mean=as.matrix(m),sigma=diag(s))
r<-x
for(i in 1:n)
{
	r[i,]<-rank(-x[i,])
}
M<-600
Mx<-5000

dyn.load("test/Thurstone.so")
resm<-matrix(0,nrow=M,ncol=p)
ress<-matrix(0,nrow=M,ncol=1)
#res1<-.C("PF",as.integer(M), as.integer(Mx),as.integer(r), as.integer(p), as.integer(n),m=as.double(resm),s=as.double(ress))
t<-proc.time()
res1<-.C("fPGibbs",as.integer(M), as.integer(r), as.integer(p), as.integer(n),m=as.double(resm),s=as.double(ress))
m1t<-proc.time()-t
t<-proc.time()
res2<-.C("Gibbs",as.integer(M), as.integer(r), as.integer(p), as.integer(n),m=as.double(resm),s=as.double(ress))
m2t<-proc.time()-t
mp1<-matrix(res1$m,ncol=p)
sp1<-matrix(res1$s,ncol=1)
mp2<-matrix(res2$m,ncol=p)
sp2<-matrix(res2$s,ncol=1)

dyn.unload("test/Thurstone.so")
